﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JqueryNet.FormControl.FormHtmlControl
{
    public class JHtmlTableRow : JHtmlControl
    {
        private System.Web.UI.HtmlControls.HtmlTableRow htmlTableRow;

        public JHtmlTableRow(System.Web.UI.HtmlControls.HtmlTableRow htmlTableRow)
            : base(htmlTableRow)
        {
            // TODO: Complete member initialization
            this.htmlTableRow = htmlTableRow;
        }

        public override void Attr(string key)
        {
            switch (key.ToLower())
            {
                case "align":
                    Value = htmlTableRow.Align;
                    return;
                case "bgcolor":
                    Value = htmlTableRow.BgColor;
                    return;
                case "bordercolor":
                    Value = htmlTableRow.BorderColor;
                    return;
                case "cells":
                case "cell":
                    Value = htmlTableRow.Cells;
                    return;
                case "height":
                    Value = htmlTableRow.Height;
                    return;                
                    return;
                case "valign":
                    Value = htmlTableRow.VAlign;
                    return;
                default:
                    base.Attr(key); return;
            }
        }

        public override void Html()
        {
            Value = htmlTableRow.InnerHtml;
        }

        public override void Html(Func<string> fun)
        {
            htmlTableRow.InnerHtml = fun();
        }

        public override void Html(string value)
        {
            htmlTableRow.InnerHtml = value;
        }

        public override void Text()
        {
            Value = htmlTableRow.InnerText;
        }

        public override void Text(Func<string> fun)
        {
            htmlTableRow.InnerText = fun();
        }

        public override void Text(string value)
        {
            htmlTableRow.InnerText = value;
        }


        public override void Attr(string key, string value)
        {
            int b;
            int.TryParse(value, out b);
            bool f;
            bool.TryParse(value, out f);
            switch (key.ToLower())
            {
                case "align":
                    htmlTableRow.Align = value;
                    return;
                case "bgcolor":
                    htmlTableRow.BgColor = value;
                    return;
                case "bordercolor":
                    htmlTableRow.BorderColor = value;
                    return; 
                case "height":
                    htmlTableRow.Height = value;
                    return; 
                case "valign":
                    htmlTableRow.VAlign = value;
                    return; 
                default:
                    base.Attr(key, value); return;
            }
        }
    }
}
